<?php
namespace app\common\validate;

/**
 * Class Validate
 * @package app\common\validate
 * @author jwj <jwjbjg@gmail.com>
 * @copyright jwj
 */
class Validate extends \think\Validate
{
    /**
     * 获取验证场景需要验证的字段
     * @return array
     */
    public function getSceneField()
    {
        $this->getScene($this->currentScene);

        $rules = $this->rule;
        foreach ($this->append as $key => $rule) {
            if (!isset($rules[$key])) {
                $rules[$key] = $rule;
            }
        }

        $fields = [];
        foreach ($rules as $key => $rule) {
            if (strpos($key, '|'))  $key = explode('|', $key)[0];

            if (!empty($this->only) && !in_array($key, $this->only)) continue;

            if (isset($this->remove[$key]) && true === $this->remove[$key]) continue;

            $fields[] = $key;
        }

        return $fields;
    }
}